<div style="width:100%;overflow:auto;">
	<br />
	<a href="javascript:viewDBTable();">View another table</a>
	<?php
		require_once("../functions.php");
		
		connectToDB();
		$result = mysql_query("select * from " . trim($_REQUEST["table"]));
		$nrows = mysql_num_rows($result);
		
		echo "<br/><h4 class='center'>" . strtoupper($_REQUEST["table"]) . "</h4><br/>";
		if ($nrows > 0) {
			echo "<table border='1' cellspacing='0' cellpadding='1'>\n";
			$printHeader = true;
			while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
				echo "<tr>\n";
				if($printHeader){
					foreach ($row as $key => $val) {
						echo "<th>$key</th>\n";
					}
					$printHeader = false;
				}
				echo "</tr>\n";
				echo "<tr>\n";
				foreach ($row as $data) {
					echo "<td>$data</td>\n";
				}
				echo "</tr>\n";
			}
			echo "</table>\n";
		} else {
			echo "No data found<br />\n";
		}
		echo "<br />$nrows Rows Selected<br />\n";
		
		mysql_free_result($result);
	?>
</div>